<template>
	<div class="publicformview">
		<!-- <el-button type="primary" size="mini" @click="handleUpdate()">录入</el-button> -->
		<div class="bottomTop" style="margin-top: 10px;">
			<el-table max-height='500px' v-loading="listLoading" :data="list" border fit highlight-current-row size="mini">
				<el-table-column align="center" label="所号" prop="blockNo">
				</el-table-column>

				<el-table-column align="center" label="管片" prop="blockgroup">
				</el-table-column>

				<el-table-column align="center" label="开始时间" prop="startTime">
				</el-table-column>

				<el-table-column align="center" label="结束时间" prop="endTime">
				</el-table-column>

				<!-- <el-table-column align="center" label="变更记录" prop="changememo1">
				</el-table-column>
				<el-table-column align="center" label="操作" width="280">
					<template slot-scope="scope">
						<el-button type="text" size="mini" @click="handleUpdate(scope.row.changeid)">修改</el-button>
					</template>
				</el-table-column> -->
			</el-table>
		</div>
		<div class="publicpaginationview">
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
				:current-page="listQuery.pageNum" background :page-sizes="[10, 20, 50, 100]" :page-size="listQuery.pageSize"
				layout="total, sizes, prev, pager, next, jumper" :total="total" small></el-pagination>
		</div>

		<el-dialog title="" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
			<el-form :model="addQuery" ref="dataForm" class="demo-ruleForm" label-position="right" label-width="150px">
				<el-form-item label="序号：" prop="orderno">
					<el-input v-model="addQuery.orderno"></el-input>
				</el-form-item>
				<el-form-item label="地点：" prop="address">
					<el-input v-model="addQuery.address"></el-input>
				</el-form-item>
				<el-form-item label="间号：" prop="roomno">
					<el-input v-model="addQuery.roomno"></el-input>
				</el-form-item>
				<el-form-item label="变更记录：" prop="changememo1">
					<el-input v-model="addQuery.changememo1"></el-input>
				</el-form-item>
			</el-form>
			<div class="saveContent">
				<el-button type="primary" @click="save" size="medium">保 存</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import dayjs from 'dayjs'
	import {
		addBlockChange,
		blockHisBlockGroup,
		updBlockChange,
		blockChangeData
	} from '@/api/industry'
	export default {
		props: {
			blockType: String,
			blockid: String,
			blockno: String
		},
		name: "fangwuxianzhuang",
		data() {
			return {
				listQuery: {
					pageNum: 1,
					pageSize: 20
				},
				addQuery: {
					changememo1: '',
					roomno: '',
					address: '',
					orderno: ''
				},
				total: 0,
				options: [{
					key: "1"
				}],
				list: [],
				listLoading: false,
				dialogVisible: false,
				isChanquan: true,
				type: 1,
				changeid: ''
			};
		},

		mounted() {
			this.blockHisBlockGroup()
		},

		methods: {
			blockHisBlockGroup() {
				
				if(this.blockno){
					let data = {
						blockNo: this.blockno,
						pageNum:this.pageNum,
						pageSize:this.pageSize
					}
					blockHisBlockGroup(data).then(res => {
						console.log(res)
						this.list = res.data.list
						this.total = res.data.total
					})
				}
			},
			handleUpdate(changeid) {
				this.changeid = changeid
				this.dialogVisible = true;
				if(changeid){
					let data = {
						changeId:changeid
					}
					blockChangeData(data).then(res=>{
						console.log(res)
						this.addQuery = res.data
					})
				}
			},
			save() {
				let data = this.addQuery
				if (this.changeid) {
					data.changeid = this.changeid
					updBlockChange(data).then(res => {
						console.log(res)
						this.dialogVisible = false;
						this.blockHisBlockGroup()
						this.$message({
							type: 'success',
							message: '操作成功!'
						});
					})
				} else {
					addBlockChange(data).then(res => {
						console.log(res)
						this.dialogVisible = false;
						this.blockHisBlockGroup()
						this.$message({
							type: 'success',
							message: '操作成功!'
						});
					})
				}
				this.reter()
			},
			reter(){
				this.addQuery.changememo1= '',
				this.addQuery.roomno= '',
				this.addQuery.address= '',
				this.addQuery.orderno= '',
				this.changeid = ''
			},
			handleSizeChange(val) {
				this.listQuery.pageNum = 1;
				this.listQuery.pageSize = val;
				this.blockHisBlockGroup()
			},
			handleCurrentChange(val) {
				this.listQuery.pageNum = val;
				this.blockHisBlockGroup()
			},
			resetForm(val) {
				console.log("1");
				this.$refs[val].resetFields();
			},
			handleAddUser(type) {
				this.isChanquan = type == 1 ? true : false
			},
			returns() {
				this.$router.go(-1)
			},
			// 选择类型
			selectButton(type) {
				this.type = type
			},
			handleClose(done) {
				this.$confirm('确认关闭？')
					.then(_ => {
						done();
						this.reter()
					})
					.catch(_ => {});
			}
		},
	};
</script>

<style scoped>
	.headTop {
		width: 100%;
		display: flex;
		justify-content: space-between;

		.xinxi {
			display: flex;
			width: 800px;
		}
	}

	.el-form-item {
		justify-content: start !important;
	}

	.el-select {
		width: 180px;
	}



	.el-date-picker {
		width: 180px;
	}

	.bottomTop {
		width: 100%;
		display: flex;
		justify-content: end;
	}

	.tabButton {
		background: #EFF2F7;
		color: #333333;
		border: none;
	}

	.fangwuList {
		width: 100%;
		background-color: #F5F5F5;
		margin: 3px auto 0;
		overflow: hidden;
	}

	.fangwuText {
		font-weight: bold;
		font-size: 16px;
		color: #008C93;
		margin-top: 20px;
		margin-left: 26px;
	}

	.saveContent {
		width: 100%;
		display: flex;
		justify-content: end;
		margin-top: 20px;
		padding-bottom: 20px;
	}
</style>